import socket

# 创建 socket 对象
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# 连接服务器
# ip 和 port(端口号), windows中localhost代表本机服务
server_address = ('localhost', 12345)
client_socket.connect(server_address)

# 发送和接收数据
message = 'Hello, Server!'
client_socket.sendall(message.encode())

data = client_socket.recv(1024)
print('收到服务器的回复:', data.decode())

# 关闭连接
client_socket.close()
